/*var status = 0;
var stars = Array(2070001, 2070002, 2070003, 2070004, 2070005, 2070006, 2070016, 2070018);
var text = "";
var materials = Array();
var quantity = Array();
var chosen = 0;
var continuez = true;

function start() {
	status = -1;
	action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == -1) {
		cm.dispose();
	} else {
		if (mode == 0) {
			cm.sendOk("I see, goodbye");
			cm.dispose();
			return;
		}
		if (mode == 1)
			status++;
		else
			status--;
		if (status == 0) {
			cm.sendYesNo("Hey, I am the brother of Tylus\r\nI can make you a nice set of stars\r\nWhat do you say, want to have some nice stars?");
		} else if (status == 1) {
			text += "What stars would you like to create?#b";
			for (var i = 0; i < stars.length; i++) {
				text += "\r\n#L" + i + "##t" + stars[i] + "# (#i" + stars[i] + "#)#l";
			}
			cm.sendSimple(text);
		} else if (status == 2) {
			chosen = selection;
			switch (chosen) {
				case 0:
					materials = Array(2070000, 4011000, 0);
					quantity = Array(500, 1, 1000);
					break;
				case 1:
					materials = Array(2070001, 4011001, 0);
					quantity = Array(500, 2, 2000);
					break;
				case 2:
					materials = Array(2070002, 4011002, 0);
					quantity = Array(500, 3, 5000);
					break;
				case 3:
					materials = Array(2070003, 4011003, 0);
					quantity = Array(500, 4, 10000);
					break;
				case 4:
					materials = Array(2070004, 4011004, 0);
					quantity = Array(500, 5, 20000);
					break;
				case 5:
					materials = Array(2070005, 4011005, 0);
					quantity = Array(500, 10, 50000);
					break;
				case 6:
					materials = Array(2070006, 4011006, 0);
					quantity = Array(500, 10, 100000);
					break;
				case 7:
					materials = Array(2070016, 4011007, 0);
					quantity = Array(500, 1, 500000);
					break;
				default:
					cm.sendOk("Error, please state this to Bassoe");
					cm.dispose();
					return;
			}
			text = ("To make a #v" + stars[chosen] + "# you will need:\r\n");
			for (var a = 0; a < materials.length; a++) {
				if (materials[a] != 0) {
					text += ("#b" + quantity[a] + "#k #t" + materials[a] + "# (#v" + materials[a] + "#)\r\n");
				} else {
					text += ("#b" + quantity[a] + "#k mesos");
				}
			}
			text += "\r\n\r\nDo you have those materials?";
			cm.sendYesNo(text);
		} else {
			for (var l = 0; l < materials.length; l++) {
				if (materials[l] != 0) {
					if (cm.itemQuantity(materials[l]) >= quantity[l])
						continuez = true;
					else {
						continuez = false;
						break;
					}
				} else {
					if (cm.getChar().getMeso() >= quantity[l])
						continuez = true;
					else {
						continuez = false;
						break;
					}
				}
			}
			if (continuez) {
				for (var z = 0; z < materials.length; z++) {
					if (materials[z] != 0) 
						cm.gainItem(materials[z], -(quantity[z]));
					else
						cm.gainMeso(-(quantity[z]));
				}
				cm.gainItem(stars[chosen], 500);
				cm.sendOk("I have given you your star");
			} else
				cm.sendOk("You do not have the right materials\r\nOr you don't have enough mesos");
			cm.dispose();
		}
	}
}*/

var status = 0;
var text = "Hello #h #, Welcome to #rChickenMS!#k\r\nWhat do you want to do?\r\n#L1##bTrade #i4000422# for 500 NX#l\r\n#L2##bTrade #i4000423# for 1k NX#k#l\r\n#L3##bTrade #i4000424# for 2.5k NX#k#l\r\n#L4##bTrade #i4000425# for 5k NX#k#l\r\n#L5##bI have way too much mesos O.o#k#l\r\n#L6##eEww, you are ugly, i won't talk to you!#n#l";

function start() {
	status = -1;
	action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == -1) {
		cm.dispose();
	} else {
		if (mode == 0 && status == 0) {
			cm.dispose();
			return;
		}
		if (mode == 1)
			status++;
		else
			status--;
		if (status == 0) {
			cm.sendSimple(text);
		} else if (status == 1) {
			if (selection == 1) {
				if (cm.itemQuantity(4000422) >= 1 ) {
					cm.gainItem(4000422, -1);				
					cm.gainNX(500);
					cm.dispose();
				} else {
					cm.sendOk("You don't have enough #i4000422#\r\nDon't scam me or I will use this on you! #s5001001#");
					cm.dispose();
				}								
			} else if (selection == 2) {
				if (cm.itemQuantity(4000423) >= 1 ) {
					cm.gainItem(4000423, -1);				
					cm.gainNX(1000);
					cm.dispose();
				} else {
					cm.sendOk("You don't have enough #i4000423#\r\nDon't scam me or I will use this on you! #s5001001#");
					cm.dispose();
				}
			} else if (selection == 3) {
				if (cm.itemQuantity(4000424) >= 1 ) {
					cm.gainItem(4000424, -1);				
					cm.gainNX(2500);
					cm.dispose();
				} else {
					cm.sendOk("You don't have enough #i4000424#\r\nDon't scam me or I will use this on you! #s5001001#");
					cm.dispose();
				}
			} else if (selection == 4) {
				if (cm.itemQuantity(4000425) >= 1 ) {
					cm.gainItem(4000425, -1);				
					cm.gainNX(5000);
					cm.dispose();
				} else {
					cm.sendOk("You don't have enough #i4000425#\r\nDon't scam me or I will use this on you! #s5001001#");
					cm.dispose();
				}
			} else if (selection == 5) {
				cm.sendSimple("Ooh! i know that problem\r\n\r\n#L1##bI want to trade 1bil mesos for 1 #i4031476##l\r\n#L2#I want to trade 1 #i4031476# for 1bil mesos#k#l");
			} else {
				cm.sendOk("Oh. i see... Well then, have fun in #rChickenMS!#k\r\n\r\n#e*cries*#n");
				cm.dispose();
			}
		} else {
			if (selection == 1) {
				if (cm.getMeso() >= 1000000000) {
					cm.gainMeso(-1000000000);
					cm.gainItem(4031476, 1);
					cm.dispose();
				} else {
					cm.sendOk("You don't have enough mesos!");
					cm.dispose();
				}
			} else {
				if (cm.itemQuantity(4031476) >= 1) {
					if (cm.getMeso() >= 1147483648) {
						cm.sendOk("You have way too much mesos\r\nI cant give you 1 bil");
						cm.dispose();
					} else {
						cm.gainItem(4031476, -1);
						cm.gainMeso(1000000000);
						cm.dispose();
					}
				} else {
					cm.sendOk("You don't have a #i4031476#");
					cm.dispose();
				}
			}
		}
	}
}